package com.claude.mainactivity;


import com.special.ResideMenuDemo.R;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;

public class MainActivity extends Activity {
	private Button mBtn = null;
	private MyApplication mMyApplication = null;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		mMyApplication = (MyApplication) getApplication();
		
		this.initView();

	}

	public void onStart() {
		super.onStart();
	}

	public void onResume() {
		super.onResume();
	}

	public void onRestart() {
		super.onRestart();
	}

	public void onPause() {
		super.onPause();
	}

	public void onStop() {
		super.onStop();
	}

	public void onDestory() {
		super.onDestroy();
	}

	private void initView() {
		mBtn = (Button) findViewById(R.id.btn);
		mBtn.setOnClickListener(new MyOnClickListener());
	}

	class MyOnClickListener implements OnClickListener {
		public void onClick(View view) {
			gotoSelectClass();
		}
	}

	private void gotoSelectClass() {
		Intent intent = new Intent();
		intent.setClass(MainActivity.this, SubjectSelectActivity.class);
		MainActivity.this.startActivity(intent);		
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent keyEvent){
		if(keyCode == KeyEvent.KEYCODE_BACK){
			quitSystem();
		}
		return false;
	}
	
	private void quitSystem(){
		Builder dialog = new AlertDialog.Builder(MainActivity.this)
		.setMessage("确定要退出考勤系统？")
		.setPositiveButton("确定", new Dialog.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				MainActivity.this.finish();
			}
		}).setNegativeButton("取消", new Dialog.OnClickListener(){
			public void onClick(DialogInterface dialog, int which) {
			}
		});
		dialog.show();
	}
}
